#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;

int n;
int q[N], dis[N], cnt[N];

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    scanf("%d", &n);
    for(int i = 0; i < n; i ++) scanf("%d", &q[i]);


    for(int i = 0; i < n; i ++){
        if(q[i] >= i){
            dis[i] = q[i] - i;
        }else{
            dis[i] = n - i + q[i];
        }
    }



    for(int i = 0; i < n; i ++){
        cnt[dis[i]] ++;
    }

    int maxv = 0;
    for(int i = 0; i < n; i ++){
        maxv = max(maxv, cnt[(i - 1 + n) % n] + cnt[i % n] + cnt[(i + 1) % n]);
    }

    printf("%d\n", maxv);


    return 0;
}